package com.ouzexi.finalexp

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.widget.AdapterView
import android.widget.ArrayAdapter
import android.widget.ListView
import com.ouzexi.finalexp.adapter.PositionAdapter
import com.ouzexi.finalexp.util.save

class RecIndex : AppCompatActivity() {
    lateinit var token: String

    private val pos = listOf("后端", "前端", "运维")

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_rec_index)

        token = save().getData(this, "token")

        // 获取ListView组件
        val List = findViewById<ListView>(R.id.List)

        val adapter = ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, pos)
        List?.adapter = adapter

        // 点击监听器 转到岗位详情
        List.onItemClickListener = AdapterView.OnItemClickListener { parent, view, position, id ->
            Log.i("testClick", "ClickListen")
            if(id.toString() == "0"){
                Log.i("testid",id.toString())
                val intent = Intent(this, index::class.java)
                intent.putExtra("jid","1408053861153345556")
                intent.putExtra("jtypename","后端")
                startActivity(intent)
            }
            else if(id.toString() == "1"){
                Log.i("testid",id.toString())
                val intent = Intent(this, index::class.java)
                intent.putExtra("jid","1408053861153345557")
                intent.putExtra("jtypename","前端")
                startActivity(intent)
            }
            else{
                Log.i("testid",id.toString())
                val intent = Intent(this, index::class.java)
                intent.putExtra("jid","1408053861153345558")
                intent.putExtra("jtypename","运维")
                startActivity(intent)
            }

        }
    }
}